home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / BKISSSRC.ZIP / BOUNCE / DRAWSTRX.INC < prev    next >
Encoding:
Text File  |  1994-02-10  |  4.2 KB  |  107 lines

  1. ;this module is a slightly modified version of Patch's original routine
  2. ;this adds in a sinewave to translate each column of the text vertically
  3. ;and also a scale value which affects how much effect the sine wave has
  4. ;on the text
  5.  
  6. TransparentText = 1     ;set to 0 to draw backgrounds of letters
  7. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  8. ; void far Draw_String(byte far *fontdata, byte far *string,
  9. ;                  word xcoord, word ycoord, word pageoffs);
  10. ;
  11. PROC            _Draw_String far
  12. mov [@@Angle],si
  13. mov [@@Scale],ebx
  14.                 push bp
  15.                 mov bp,sp
  16.                 push ds
  17.  
  18.                 mov ax,0A000h
  19.                 mov es,ax
  20.  
  21.                 lds si,[dword bp + 6]               ; DS:SI -> fontdata
  22.                 add si,3                            ; point to offset table
  23.                 mov dx,[bp + 14]                    ; X coord
  24.  
  25.                 mov di,[bp + 16]                    ; Y coord
  26.                 shl di,4                            ; *16
  27.                 mov bx,di                           ; save
  28.                 shl di,2                            ; *64
  29.                 add di,bx                           ; *64 + *16 = *80
  30.  
  31.                 mov cl,dl                   ; get plane bits from X pos
  32.                 and cl,00000011b            ; keep in 0-3 range
  33.                 mov ah,00010001b            ; start at plane 0
  34.                 rol ah,cl                   ; shift to proper plane
  35.  
  36.                 shr dx,2                    ; divide X coord by 4
  37.                 add di,dx                   ; video offset to start at
  38.                 add di,[bp + 18]            ; final video offset
  39.  
  40.                 lfs bx,[dword bp + 10]      ; FS:BP -> string
  41.                 mov bp,bx
  42.                 mov al,02h                          ; 02h = map mask index
  43.  
  44. @@setupletter:  xor bh,bh
  45.                 mov bl,[byte fs:bp]                 ; load letter from message
  46.                 shl bx,1                            ; *2 = word sized
  47.  
  48.                 mov cx,[word si + bx]
  49.                 mov gs,si                           ; save font pointer
  50.                 sub si,3                            ; back to start
  51.                 add si,cx                           ; point to proper spot in font file
  52.  
  53.                 mov ch,[byte si + 1]                ; get X size
  54.                 mov cl,[byte si + 2]                ; get Y size
  55.                 jcxz @@nextcharacter
  56.                 add si,03h                          ; point to start of data
  57.  
  58. @@newplane:     mov dx,03c4h                        ; sequencer reg
  59.                 out dx,ax
  60.                 mov dl,cl                           ; loop Y count
  61.  
  62. push dx ax
  63. mov bx,[@@Angle]            ;\
  64. shl bx,1                    ; \
  65. movsx eax,[Sine+bx]         ;  \
  66. imul [@@Scale]              ;   > AX = round(4 ∙ scale ∙ sin(Θ))
  67. sar eax,(8-2)               ;  /
  68. add eax,8000h               ; /
  69. shr eax,16                  ;/
  70. imul ax,320/4               ;AX = row offset
  71. add [@@Angle],32            ;\ rotate 11.25°
  72. and [@@Angle],1023          ;/
  73.  
  74.                 mov bx,di                           ; save video pointer
  75. add di,ax
  76. pop ax dx
  77.  
  78. @@drawcolumn:   mov dh,[byte si]                    ; draw a column
  79.                 if TransparentText ne 0
  80.                     or dh,dh
  81.                     jz @@dontplot
  82.                 endif
  83.                 mov [es:di],dh
  84. @@dontplot:     inc si                              ; next byte in column
  85.                 add di,80                           ; next video line
  86.                 dec dl                              ; decrement height
  87.                 jnz @@drawcolumn
  88.                 mov di,bx                           ; restore video pointer
  89.  
  90.                 rol ah,1
  91.                 adc di,0
  92.                 dec ch
  93.                 jnz @@newplane
  94.  
  95. @@nextcharacter:mov si,gs
  96.                 inc bp                              ; next letter in message
  97.                 cmp [byte fs:bp],00h
  98.                 jne @@setupletter
  99.  
  100.                 pop ds
  101.                 pop bp
  102.                 ret
  103. @@Angle         dw 0
  104. @@Scale         dd 0
  105. ENDP            _Draw_String
  106. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  107.